package com.woniuxy.his.mapper;

import com.woniuxy.his.entity.PresDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.his.vo.OutMedicineDetailVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 处方详情表 Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2021-08-24
 */
public interface PresDetailMapper extends BaseMapper<PresDetail> {

    //    @Select("<script>" +
//            "select m.product_name,m.product_format,hpd.medicine_num,m.product_retail_price" +
//            " from his_pres_detail hpd, medicine m " +
//            "where hpd.medicine_id=m.id and prescription_id in " +
//            "<foreach  item= 'item' index='index' collection='list' open='(' separator=',' close=')' >" +
//            " #{item} " +
//            "</foreach> " +
//            "</script>" )
    @Select("select hp.prescription_price,m.product_name,m.product_format,hpd.medicine_num,m.product_retail_price " +
            "from his_pres_detail hpd, medicine m,his_prescription hp " +
            "where hpd.medicine_id=m.id and hp.prescription_id = #{prescriptionId} and hpd.prescription_id=hp.prescription_id")
    List<OutMedicineDetailVo> getMedicenesDetail(Integer prescriptionId);

    @Select("<script>" +
            "select m.product_name,m.product_format,hpd.medicine_num,m.product_retail_price" +
            " from his_pres_detail hpd, medicine m " +
            "where hpd.medicine_id=m.id and prescription_id in " +
            "<foreach  item= 'item' index='index' collection='list' open='(' separator=',' close=')' >" +
            " #{item} " +
            "</foreach> " +
            "</script>" )
    List<OutMedicineDetailVo> getMedicenesDetail(@Param("list") List<String> list);

}
